<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
  <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
  <title>学术</title>
  <style>
		html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
    .h20 {height: 0.5rem;background: #f0f0f0;margin: 0 -1rem;}

    .xljcList ul {
      background: #f0f0f0;
    }
    .xljcList .aui-list-item {
      background: #fff;
      /*margin: 1rem 0 0;*/
    }
    .xljcList .aui-media-list-item-inner1 .aui-list-item-title {
      font-weight: bold;
      font-size: 0.75rem;
    }
    .xljcList .aui-media-list-item-inner1 .aui-list-item-right span {
      color: #ffbc69;
      font-weight: normal;
    }
    .xljcList .aui-media-list-item-inner1 .aui-list-item-text {
      font-size: 0.65rem;
      color: #999;
    }
    .xljcList .aui-media-list-item-inner2 .aui-list-item-inner {
      padding-top: 0;
    }
    .xljcList .aui-media-list-item-inner2 .aui-list-item-title {
      color: #666;
      font-size: 0.7rem;
    }
    .xljcList .aui-media-list-item-inner2 .aui-list-item-text {
      color: #ccc;
      font-size: 0.65rem;
    }
    .itemIco {
      width: 3rem;
      height: 3rem;
      border-radius: 50%;
    }
	</style>
</head>
<body>
<section class="aui-refresh-content">
<div class="xljcList" id="app" v-cloak>
  <ul class="aui-list aui-media-list">
    <li class="aui-list-item aui-list-item-middle" tapmode="presshover" @click="openPage('jk_introduce','医生介绍', item.id, item.online)" v-for="item in newsList">
      <div class="h20"></div>
      <div class="aui-media-list-item-inner aui-media-list-item-inner1">
        <div class="aui-list-item-media" style="width: 4rem;">
          <!-- <img :src="item.head_img" class="aui-img-round aui-list-img-sm"> -->

          <div v-if="item.head_img" class="itemIco" :style="'background: url('+ item.head_img +') center/cover no-repeat'"></div>
          <div v-else class="itemIco" style="background: url(../../image/wdr@3x.png) center/cover no-repeat"></div>
        </div>
        <div class="aui-list-item-inner">
          <div class="aui-list-item-text">
            <div class="aui-list-item-title aui-font-size-14">{{item.doctorname}}</div>
            <div class="aui-list-item-right"><span v-if="item.online == 0" style="color: #999">离线</span><span v-else-if="item.online == 1">在线</span></div>
          </div>
          <div class="aui-list-item-text">
            {{item.post}}
          </div>
        </div>
      </div>
      <div class="aui-media-list-item-inner aui-media-list-item-inner2">
        <div class="aui-list-item-inner">
          <div class="aui-list-item-text">
            <div class="aui-list-item-title">{{item.introduces}}</div>
          </div>
          <div class="aui-list-item-text aui-ellipsis-2">
            已有{{item.servenum}}人咨询过
          </div>
        </div>
      </div>
    </li>
  </ul>
</div>
</section>

</body>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">
apiready = function() {

  var app = new Vue({
    el: '#app',
    data: {
      newsList: [],
      page: 1,
      totalpage: 1
    },
    created: function() {
      var $_this = this;
      api.ajax({
       url: window.Url.getCertificationList + $_this.page,
        timeout: 300,
      }, function(ret, err) {
          if (ret) {
              console.log(JSON.stringify(ret));
              // api.alert({ msg: JSON.stringify(ret) });
              if (ret.data == null) return
              $_this.newsList = ret.data.newsList
          } else {
              api.alert({ msg: JSON.stringify(err) });
          }
      })

      var scroll = new auiScroll({
            listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
            distance:40 //判断到达底部的距离，isToBottom为true
        },function(ret){
           if (ret.isToBottom) {
             $_this.page ++
             if ($_this.page > $_this.totalpage) {
               $_this.page = $_this.totalpage
               return
             }
             api.ajax({
     				  url: window.Url.getCertificationList + $_this.page,
     					timeout: 300,
     				}, function(ret, err) {
     				    if (ret) {
     				       //  api.alert({ msg: JSON.stringify(ret) });
     								$_this.newsList = $_this.newsList.concat(ret.data.newsList)

     				    } else {
     				        api.alert({ msg: JSON.stringify(err) });
     				    }
     				})
           }

        });

        var pullRefresh = new auiPullToRefresh({
            container: document.querySelector('.aui-refresh-content'),
            triggerDistance: 100
        },function(ret){
            if(ret.status=="success"){
              $_this.page = 1
              api.ajax({
               url: window.Url.getCertificationList + $_this.page,
                timeout: 300,
              }, function(ret, err) {
                  if (ret) {
                      // api.alert({ msg: JSON.stringify(ret) });
                      setTimeout(function() {
                        if (ret.data == null) {
                          pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                          return;
                        }
                        $_this.newsList = ret.data.newsList
                          pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                      },500)
                  } else {
                      api.alert({ msg: JSON.stringify(err) });
                  }
              })
            }
        })
    },
    methods: {
      openPage: function (type, title, id, online) {
        api.openWin({
          name: 'index_' + type,
          pageParam: {
            name: 'index_' + type,
            title: title,
            id: id,
            online: online
          },
          url: './first_header.html',
          delay: 200,
          bounces: false
        });
      }
    }
  })
}


</script>
</html>
